/*###################################################################*
#
# MP (Mitchell Pell) Base - CrossPlatform Base Utilities.
# Copyright (C) 2014  Mitchell Pell
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
####################################################################*/
#ifndef BASE_CONSOLE_H
#define BASE_CONSOLE_H

#include <vector>
#include <string>

#if defined(WIN32)
#include <conio.h>
#else
#include "../common/conio.h"
#endif

#include "Error.h"
#include "RecursiveLockingMutex.h"
#include "Pause.h"
#include "ReceivesErrors.h"

using namespace std;
using namespace mp_base::interfaces;
using namespace mp_base::utility;

namespace mp_base { 
	/*! @brief General console.*/
	namespace console {

		typedef vector<string> vStrings;
		typedef vector<string>::const_iterator ciString;

		/*!----------------------------------------------------------------
		*	@class		Console
		*	@brief		Basic console for sending messages and errors to
		*				the system console, if available, and also storing
		*				them for access by the program.
		*
		*	@author		Mitchell Pell
		*	@date		12/04/2013
		*	@version	1.1
		*
		*	@revisions	Revision History:
		*
		*					- Version 1.1 12/04/2013
		*						-# Added RecursiveLockingMutex support
		*					- Version 1.0 11/23/2013
		*						-# Initial Make
		*
		-----------------------------------------------------------------*/
		class Console : public RecursiveLockingMutex, public ReceivesErrors
		{
		public://GetMessage
			Console(){  }

			void WriteMessage(const string msg);
			void WriteMessage(const char* msg);
			void WriteMessage(const Event& msg);


			void WriteError(const char*er);
			void WriteError(const std::string er);
			void WriteError(const Error& er);

			const ciString GetConsoleMessagesEnd() const
				{ return m_consoleMessages.end();}
			const ciString GetConsoleMessagesBegin() const
				{ return m_consoleMessages.begin();}

			const ciString GetConsoleErrorsEnd() const
				{ return m_consoleErrors.end();}
			const ciString GetConsoleErrorsBegin() const
				{ return m_consoleErrors.begin();}

		protected:
			vStrings m_consoleMessages;
			vStrings m_consoleErrors;

		public:
			static const string CONSOLE_MESSAGE_PREFIX;
			static const string CONSOLE_ERROR_PREFIX;
		};
	}
}

#endif